addBcd1   PROC NEAR32
; add two non-negative 10 byte packed BCD numbers
; parameter1:  address of operand1 (and destination)
; parameter2:  address of operand2
; author:  R. Detmer     revised: 5/98
          push ebp            ; establish stack frame
          mov  ebp, esp
          push esi            ; save registers
          push edi
          push ecx
          push eax
          mov  edi, [ebp+12]  ; destination address
          mov  esi, [ebp+8]   ; source address

          clc                 ; clear carry flag for first add
          mov  ecx, 9         ; count of bytes to process
forAdd:   mov  al, [edi]      ; get one operand byte
          adc  al, [esi]      ; add other operand byte
          daa                 ; adjust to BCD
          mov  [edi], al      ; save sum
          inc  edi            ; point at next operand bytes
          inc  esi
          loop forAdd         ; repeat for all 9 bytes

          pop  eax            ; restore registers
          pop  ecx
          pop  edi
          pop  esi
          pop  ebp
          ret  8              ; return to caller

addBcd1   ENDP

